package com.yami.shop.multishop.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yami.shop.bean.enums.EsOperationType;
import com.yami.shop.bean.event.ZteFileUploadEvent;
import com.yami.shop.common.bean.PageDTO;
import com.yami.shop.common.bean.PageVO;
import com.yami.shop.common.response.ServerResponseEntity;
import com.yami.shop.common.util.PageParam;
import com.yami.shop.nft.common.model.NftApply;
import com.yami.shop.nft.common.model.NftApplyImg;
import com.yami.shop.nft.common.service.NftApplyImgService;
import com.yami.shop.nft.common.service.NftApplyService;
import com.yami.shop.security.multishop.util.SecurityUtils;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Param;
import org.springdoc.api.annotations.ParameterObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationEventPublisher;
import org.springframework.web.bind.annotation.*;

@Slf4j
@RestController
@RequestMapping("/m/nftapply")
@Tag(name = "店铺端提交铸币审核")
public class NftApplyController {

    @Autowired
    private NftApplyService nftApplyService;

    @Autowired
    private NftApplyImgService nftApplyImgService;


    @GetMapping("/pageNftApplyList")
    @Operation(summary = "分页申请铸币列表信息", description = "分页申请铸币列表信息")
    public ServerResponseEntity<IPage<NftApply>> pageNftApplyList(@ParameterObject NftApply nftApply, PageParam<NftApply> page) {
        nftApply.setShopId(SecurityUtils.getShopUser().getShopId());
        nftApply.setShopType("2");
        return ServerResponseEntity.success(nftApplyService.getNftApplyPage(page, nftApply));
    }

    @PostMapping("/saveNftApply")
    @Operation(summary = "添加申请铸币信息", description = "添加申请铸币信息")
    public ServerResponseEntity<Void> insetApplys(@RequestBody NftApply nftApply) {
        nftApply.setShopId(SecurityUtils.getShopUser().getShopId());
        nftApplyService.saveNftApply(nftApply);
        return ServerResponseEntity.success();
    }

    @PostMapping("/updateApplyStatus")
    @Operation(summary = "修改申请铸币审核状态", description = "修改申请铸币审核状态")
    public ServerResponseEntity<Void> updateApplyStatus(@RequestBody NftApply nftApply) {
        nftApplyService.updateNftApplyById(nftApply);
        return ServerResponseEntity.success();
    }

    @GetMapping("/getNftApplyInfo")
    @Operation(summary = "铸币详情信息", description = "分页申请铸币列表信息")
    public ServerResponseEntity<NftApply> pageNftApplyList(@Param("id") Long id) {
        return ServerResponseEntity.success(nftApplyService.getNftApplyInfo(id));
    }

    @GetMapping("/pageImg")
    @Operation(summary = "铸币详情分页源文件", description = "分页申请铸币列表信息")
    public ServerResponseEntity<IPage<NftApplyImg>> pageImg(@ParameterObject NftApplyImg nftApplyImg, PageParam<NftApplyImg> page) {
        return ServerResponseEntity.success(nftApplyImgService.getNftApplyImgPage(page, nftApplyImg));
    }

}
